<template>
  <div class="about">
    <div class="head">
        <div class="top">
                <div @click="fanhui()">
                    <img src="../../assets/imageZhaoPin/返回白@2x.png" alt="">
                    <span>返回</span>
                </div>
                <div>
                    <span>新建求职</span>
                </div>
                <div @click="fabu()" style="width:42px;text-align: right;">
                    <span>发布</span>
                </div>
        </div>
    </div>
    <div class="main">
        <div class="maintext">
               <div class="choes">
                <van-field v-model="value" placeholder="请输入姓名" label="* 姓名" input-align="right" class="inp"/>
            </div>
            <div class="xian"></div>
            <div class="sa1 clear">
            <span >* 性别</span>
           <van-radio-group v-model="radio"  ref="radio" class="aa" direction="horizontal">
            <van-radio name="1" class="van" >男</van-radio>
            <van-radio name="2" class="van" >女</van-radio>
        </van-radio-group>
        </div>
        <div class="xian"></div>
        <div class="choes">
                <van-field v-model="value1" placeholder="请输入年龄" label="* 年龄" input-align="right" type="number" class="inp"/>
            </div>
            <div class="xian"></div>
            <div class="sa1 clear">
              <span style="width:110px;">* 学历</span>
              <div class="left" @click="xlshowPicker=true">
                <strong>{{xlvalue}}</strong>
                <img src="../../assets/imageZhaoPin/下拉灰@2x.png" alt="">
              </div>

              <van-popup v-model="xlshowPicker" round position="bottom">
                <van-picker
                    show-toolbar
                    :columns="xlcolumns"
                    @cancel="xlshowPicker = false"
                    @confirm="xlonConfirm"
                />
              </van-popup>
<!--            <span >* 学历</span>
           <van-radio-group v-model="radio1"  ref="radio" class="aa" direction="horizontal">
            <van-radio name="1" class="van" >本科</van-radio>
            <van-radio name="2" class="van" >大专</van-radio>
            <van-radio name="3" class="van" >高中</van-radio>
            <van-radio name="4" class="van" >其他</van-radio>
        </van-radio-group>-->
        </div>
        <div class="xian"></div>
        <div class="choes">
                <van-field v-model="value2" placeholder="请输入联系电话" label="* 联系电话" input-align="right" class="inp"/>
            </div>
            <div class="xian"></div>
            <div class="sa1 clear">
            <span style="width:110px;">* 联系地址</span>
            <div class="left" @click="show1=true">
                <strong>{{main}}</strong>
                <img src="../../assets/imageZhaoPin/下拉灰@2x.png" alt="">
            </div>
            <van-popup v-model="show1" round position="bottom" :style="{ height: '46%' }">
               <van-area title="标题" :area-list="areaList" @confirm="onAreaConfirm" @cancel="show1=false"/>
            </van-popup>
        </div>
        <div class="xian"></div>
         <div class="choes">
                <van-field v-model="value3" placeholder="请输入详细地址" label="详细地址" input-align="right" class="inp"/>
            </div>
            <div class="xian"></div>
            <div class="choes">
                <van-field v-model="value4" placeholder="请输入应聘岗位" label="* 应聘岗位" input-align="right" class="inp"/>
            </div>
            <div class="xian"></div>
            <div class="sa1 clear">
            <span style="width:110px;">* 期望地址</span>
            <div class="left" @click="show2=true">
                <strong>{{main1}}</strong>
                <img src="../../assets/imageZhaoPin/下拉灰@2x.png" alt="">
            </div>
            <van-popup v-model="show2" round position="bottom" :style="{ height: '46%' }">
               <van-area title="标题" :area-list="areaList" @confirm="onAreaConfirm1" @cancel="show2=false"/>
            </van-popup>
        </div>
        <div class="xian"></div>
        <div class="choes">
                <van-field v-model="value5" type="number" placeholder="请输入工作年限" label="* 工作年限" input-align="right" class="inp" />
            </div>
            <div class="xian"></div>
            <div class="sa clear">
            <span >工资待遇</span>
            <div class="xin clear">
                <input type="number" style="margin-right:34px;" placeholder="不限" oninput="if(value.length>5)value=value.slice(0,5)" v-model="va1">
                <input type="number" placeholder="不限" oninput="if(value.length>5)value=value.slice(0,5)" v-model="va2">
                <div class="xian1"></div>
            </div>
        </div>
        <div class="xian"></div>
        <div class="sa clear">
            <span>能力描述</span>
           <textarea placeholder="无" v-model="xox"></textarea>
        </div>
        <div class="xian"></div>
        <div class="sa clear">
            <span>个人介绍</span>
           <textarea placeholder="无" v-model="xox1"></textarea>
        </div>
        <div class="xian"></div>
        </div>
    </div>
  </div>
</template>

<script>
import AeraInfo from '../../assets/UseJS/area.js'

import {EvaluationOrderBy} from '../../apiZhaoPin/api'

export default {
  data () {
    return {
      value: '',
      value1: '',
      value2: '',
      value3: '',
      value4: '',
      value5: '',
      radio: '',
      radio1: '',
      show1: false,
      show2: false,
      areaList: AeraInfo,
      arrArea: [],
      main: '选择地区',
      main1: '选择地区',
      xox: '',
      xox1: '',
      va1: '',
      va2: '',
      sheng: '',
      shi: '',
      qu: '',
      xlshowPicker: false,
      xlcolumns: ['本科', '大专', '高中', '其它'],
      xlvalue: '请选择'
    }
  },
  methods: {
    xlonConfirm (value, index) {
      this.xlvalue = value
      this.radio1 = index + 1
      this.xlshowPicker = false
    },
    // 获取地区的方法
    onAreaConfirm (val) {
      this.show1 = false
      this.arrArea = val
      // 获取地区
      var addrInfo = val[0].name + ',' + val[1].name + ',' + val[2].name
      // this.valueArea = addrInfo
      console.log(addrInfo)
      this.main = addrInfo
      this.sheng = val[0].name
      this.shi = val[1].name
      this.qu = val[2].name
    },
    // 点击发布进行的事件
    fabu () {
      // 从本地取得穿过来的userid
      console.log(this.va1)
      console.log(this.va2)
      var id = JSON.parse(localStorage.uid).uid
      console.log(id)
      // 判断薪资的传值内容，为空时传null
      // if(this.va1=""){
      //     this.va1=null
      // }else{
      //     this.va1=this.va1
      // }
      // if(this.va2=""){
      //     this.va2=null
      // }else{
      //     this.va2=this.va2
      // }
      // 对输入内容进行限制
      if (this.value == '') {
        this.$toast('请输入姓名!')
      } else if (this.radio == '') {
        this.$toast('请选择性别!')
      } else if (this.value1 == '') {
        this.$toast('请输入年龄!')
      } else if (this.radio1 == '') {
        this.$toast('请选择学历!')
      } else if (this.value2 == '') {
        this.$toast('请输入联系电话!')
      } else if (!/^1[3456789]\d{9}$/.test(this.value2)) {
        this.$toast('联系电话格式不正确!')
      } else if (this.main == '') {
        this.$toast('请选择联系地址!')
      } else if (this.value4 == '') {
        this.$toast('请输入应聘岗位!')
      } else if (this.main1 == '') {
        this.$toast('请选择期望地址!')
      } else if (this.value5 == '') {
        this.$toast('请输入工作年限!')
      } else {
        // 请求求职发布的接口
        EvaluationOrderBy({
          SEX: this.radio,
          EDUCATION: this.radio1,
          NAME: this.value,
          AGE: this.value1,
          PHONE: this.value2,
          PROVINCE: this.sheng,
          CITY: this.shi,
          DISTRICT: this.qu,
          ADDRESS: this.value3,
          POSITION: this.value4,
          WORK_ADDRESS: this.main1,
          YEARS: this.value5,
          SALARY1: Number(this.va1),
          SALARY2: Number(this.va2),
          SKILL: this.xox,
          INTRODUCE: this.xox1
        }).then(res => {
          console.log(res)
          this.$router.go(-1)
        }).catch(err => {
          console.log(err)
        })
      }
    },
    // 获取地区方法
    onAreaConfirm1 (val) {
      this.show2 = false
      this.arrArea = val
      // 获取地区
      var addrInfo = val[0].name + ',' + val[1].name + ',' + val[2].name
      // this.valueArea = addrInfo
      console.log(addrInfo)
      this.main1 = addrInfo
    },
    // 点击返回
    fanhui () {
      this.$router.go(-1)
    }

  },
  mounted () {
    window.scrollTo(0, 0)
    document.body.style.backgroundColor = '#FAF9FE'
  },
  created () {
    document.title = '新建求职'
  }
}
</script>
<style scoped>
.clear:after {
  content: "";
  display: block;
  clear: both;
}
.clear {
  zoom: 1;
}
.about{
    position: relative;
}
.head{
    width: 100%;
    font-size: 15px;
    font-family: PingFang SC;
    font-weight: bold;
    background: linear-gradient(90deg, #1DA3F1 0%, #1DC7F1 100%);
    color:#fff;
    position: fixed;
    top: 0px;
    z-index: 5;
}
.top{
    width: 92%;
    height: 44px;
    margin: 0px auto;
    display: flex;
     justify-content:space-between;
     align-items:center;

}
.top img{
    width: 7px;
    height: 13px;
    margin-right: 5px;
    margin-top: 5px;
}
.main{
    background-color: #fff;
    margin-top: 44px;
}
.inp{
    font-size: 15px;
}
/deep/ .van-field__label span{
    font-weight: bold;
    color:#333;
}
/deep/ .van-cell{
    padding-left: 14px;
    padding-right: 14px;
}
.xian{
    width: 92%;
    margin: 0px auto;
    border-top: 0.5px solid #000;
    transform:scaleY(0.25);
    padding-bottom: 1px;
}
.sa1{
    width: 92%;
    margin: 0px auto;
    font-size: 15px;
}
.sa1 span{
    width: 100px;
   float: left;
   font-weight: bold;
    color:#333;
    margin-top: 13px;

}
.aa{
    margin-bottom: 13px;
    display: flex;
    flex-wrap:wrap;

}
.van{
    width: 60px;
    margin-right: 53.5px;
    margin-top: 13px;

}
.choes span{
    font-size: 15px;
    float: left;
}
.left{
    height: 44px;
    display: flex;
     align-items:center;
     float: right;

}
.left img{
    width: 13px;
    height: 7px;
    margin-left: 15px;
}
.left strong{
    font-weight: normal;
    color: #999;
}
/deep/ .van-field__control--right::placeholder{
  color: #999;
}
.sa{
    width: 92%;
    margin: 0px auto;
    display: flex;
     align-items:center;

}
.sa span{
    font-size: 15px;
    float: left;
    font-weight: bold;
    color:#333;
    width: 100px;
}
.sa .xin{
    float: left;
    position: relative;
}
.sa .xin input{
    float: left;
    width: 75px;
    height: 29px;
    font-size: 15px;
    text-align: center;
    margin-top: 10px;
    margin-bottom: 10px;
    border: 1px solid #E5E5E5;
    border-radius: 10px;
    background: #FAF9FE;

}
.xian1{
    width: 5px;
    border: 1px solid #000;
    position: absolute;
    top:24px;
    left: 96px;
    transform:scaleY(0.25);

}
textarea{
    height:100px;
    margin-top:15px;
    margin-bottom:15px;
    width:225px;
    line-height: 20px;
    font-size:15px;
    border: 1px solid #E5E5E5;
    /* background: #FAF9FE; */
    display: flex;
    align-items:center;
}
</style>
